package cn.cyh.user.controller;

import cn.cyh.basic.exception.BusinessException;
import cn.cyh.basic.uitls.AJaxResult;
import cn.cyh.user.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {
    @Autowired
    private IVerifyCodeService iVerifyCodeService;
    @PostMapping("/smsCode")
    public AJaxResult smsCode(@RequestBody Map<String,String> param){
        try {
            String phone = param.get("phone");
            // regist注册 type绑定
            String type = param.get("type");
            iVerifyCodeService.smsCode(param);
            return AJaxResult.myself();
        } catch (BusinessException e) {
            e.printStackTrace();
            return AJaxResult.myself().setMsg(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return AJaxResult.myself().setMsg("系统繁忙");
        }
    }
}
